<template>
  <div>
    <div class="header_search_nav search_form">
      <div class="ipt_left">
        <el-form ref="queryForm" :model="queryParams" label-width="80px">
          <el-row>
            <el-col :span="5">
              <el-form-item label="门店" prop="storeId">
                <el-select
                  v-model="queryParams.storeId"
                  placeholder="请选择"
                  filterable
                  @change="changePage"
                >
                  <el-option
                    v-for="(item, index) in $store.state.user.stores"
                    :key="index"
                    :label="item.name"
                    :value="item.id"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item prop="itemName" label="项目名称"
                ><el-input
                  class="w-200"
                  v-model="queryParams.itemName"
                  placeholder="请输入项目名称"
                  @keyup.enter.native="handleQuery"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="时间" prop="time">
                <el-date-picker
                  v-model="queryParams.time"
                  type="daterange"
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  value-format="yyyy-MM-dd HH:mm:ss"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <div class="pay_ipt">
                <el-form-item label="渠道类型" prop="channelId">
                  <el-select
                    class="w-120"
                    v-model="queryParams.channelId"
                    placeholder="请选择"
                    @change="changePage"
                  >
                    <el-option
                      v-for="item in cardTypeList"
                      :key="item.channelId"
                      :label="item.channelName"
                      :value="item.channelId"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
        </el-form>
      </div>

      <div class="btn_right">
        <button class="btn1" @click="handleQuery">筛选</button>
        <button class="btn2" @click="resetQuery">重置</button>
      </div>
    </div>

    <div class="table_card">
      <!-- 上部分 title -->
      <div class="table_card_top">
        <span class="solid_left"></span>
        <div class="table_card_title">核销记录</div>
        <div class="op_right"></div>
      </div>

      <div class="table_list">
        <el-table
          :data="VerificationList"
          stripe
          style="width: 100%"
          v-loading="loading"
        >
          <el-table-column
            prop="storeName"
            label="门店"
            :show-overflow-tooltip="true"
            width="170px"
          >
          </el-table-column>
          <el-table-column prop="custName" label="会员姓名"> </el-table-column>
          <el-table-column prop="contentName" label="项目"> </el-table-column>
          <el-table-column prop="channelMoney" label="实付金额"> </el-table-column>
          <!-- <el-table-column prop="preMoney" label="优惠金额"> </el-table-column> -->
          <!-- <el-table-column prop="realMoney" label="实际支付金额">
          </el-table-column> -->
          <el-table-column prop="cardNo" label="券码"> </el-table-column>
          <el-table-column prop="cardTypeName" label="渠道类型">
          </el-table-column>
          <el-table-column prop="createTime" label="时间"> </el-table-column>
        </el-table>
        <pagination
          :total="total"
          :page.sync="queryParams.pageNo"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </div>
    </div>
  </div>
</template>

<script>
import { getwriteOff, getAllStorelists } from "@/api/business/order";
import { getCardType } from "@/api/business/BusinessIndex";
import { getAllCardType } from "@/api/business/Subcard";
export default {
  name: "Storeadminverification",

  data() {
    return {
      VerificationList: [],
      loading: false,

      queryTypeOptions: [],

      cardTypeList: [], // 次卡类型列表
      value: "",
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        itemName: "",
        channelId: "", // 渠道类型标识
        // startTime: "", //开始时间 yyyy-MM-dd HH:mm:ss
        // endTime: "", // 结束时间
        storeId: "",
        keyword: "",
        time: [],
      },
      total: 0,
    };
  },

  mounted() {},

  created() {
    this.getList();
    this.getCardTypes();
    this.getStorelist();
  },

  methods: {
    changePage() {
      this.getList();
    },
    // 门店
    getStorelist() {
      getAllStorelists(this.queryParams)
        .then((res) => {
          const { code, data } = res;
          if (code === 0) {
            this.queryTypeOptions = data;
          }
        })
        .catch((err) => {});
    },

    // 次卡类型列表
    // getTypeList() {
    //   this.loading = true;
    //   getAllCardType({})
    //     .then((res) => {
    //       console.log(res);
    //       this.loading = false;
    //       const { code, data } = res;
    //       if (code === 0) {
    //         this.cardTypeList = data;
    //       }
    //     })
    //     .catch((err) => {
    //       this.loading = false;
    //     });
    // },

    getCardTypes() {
      this.loading = true;
      getCardType()
        .then((res) => {
          this.loading = false;
          const { code, data } = res;
          if (code === 0) {
            this.cardTypeList = data;
          }
        })
        .catch((err) => {
          this.loading = false;
        });
    },

    // 筛选
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },

    /** 重置按钮操作 */
    resetQuery() {
      this.resetFormData("queryForm");
      this.handleQuery();
    },

    // 表单重置
    resetFormData(formName) {
      console.log(this.$refs[formName]);
      this.$refs[formName].resetFields();
    },

    // 核销记录列表
    getList() {
      this.loading = true;
      let queryParams = JSON.parse(JSON.stringify(this.queryParams));

      if (!!this.queryParams.time) {
        queryParams.startTime = this.queryParams.time[0];
        queryParams.endTime = this.queryParams.time[1];
      }

      getwriteOff(queryParams)
        .then((res) => {
          console.log(res);
          this.loading = false;
          const { code, data } = res;
          if (code === 0) {
            this.VerificationList = data.list;
            this.total = data.total;
          }
        })
        .catch((err) => {
          this.loading = false;
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.goodTop {
  width: 100%;
  height: 48px;
  background: #ffffff;
  display: flex;
  font-size: 14px;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.6);
  line-height: 48px;
  padding-left: 16px;
  .good_list {
    margin-right: 32px;
  }

  .good_active {
    color: #0052d9;
    border-bottom: 1px solid #0052d9;
  }
}

.w-200 {
  width: 200px;
  background: #ffffff;
  border-radius: 4px;
}

.client_name {
  font-size: 14px;
  font-weight: 400;
  color: #0052d9;
}

.give {
  height: 40px;
  font-size: 14px;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.85);
  margin-top: 40px;
  line-height: 40px;
}

.el-form-item {
  margin-bottom: 20px;
}

.recharge_form {
  padding: 10px 24px;
}

.memberName {
  font-size: 14px;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.85);
}
.el_row_item {
  margin-bottom: 10px;
}
.el_row_date {
  margin-top: 20px;
}
.el_row_reason {
  margin-top: 10px;
}

.el_row_date {
  .el-form-item {
    margin-bottom: 0px;
  }
}

.Order_box {
  display: flex;
  margin-left: -50px;
  .select_ipt {
    width: 130px;
    margin-right: 10px;
  }
}

.pay_ipt {
  margin-left: 50px;
}

.order_ipt {
  margin-left: -120px;
}
</style>
